<?php

namespace app\factory\controller;

use app\common\respond\HttpApi;
use app\factory\logic\MedicineBoxLogic;

class MedicineBoxController
{
    /**
     * @Description 新增/编辑
     * @author: zj
     * @param HttpApi $respond
     * @time 2024/03/12 17:53:47
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function addEdit(HttpApi $respond)
    {
        $param = [
            'Id' => (int)request()->post('Id'),
            'Name' => request()->post('Name'),
            'Type' => request()->post('Type'),
            'Color' => request()->post('Color'),
            'Remark' => (int)request()->post('Remark') ?: '',
            'RecordTime' => request()->post('RecordTime')
        ];
        $rule = [
            'Id' => 'require|integer|>:0',
            'Remark' => 'max:255',
            'RecordTime' => 'require|integer|>:0',
        ];
        validate($rule)->check($param);

        $logic = new MedicineBoxLogic();
        $data = $logic->addEdit($param['Id'],$param);

        return $respond->success([]);
    }

}